package Ticketing.test02;

/**
 * @Author czl
 * @Date 2024-03-20
 */
public class Cinema implements Runnable{

    private int piao = 50;

    private  String lock = "lock";

    @Override
    public void run() {
        while (piao>=1){

            synchronized (lock){
                if (piao>0){
                    System.out.println(Thread.currentThread().getName()+"出售了第" + piao + "张票");
                    piao--;
                }

                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }


        }
    }
}
